<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Consultation extends Model
{
    //
    //use SoftDeletes;
    protected $table = 'consultation';

    public function one($id){
    	return $this->where("id", $id)->get()->toArray();
    }

    public function courseclass(){
    	return $this->belongsTo("App\Models\CourseClass", "course_class_id", "id");	
    }


    public function listinfo($where,$likeName=[]){
    	if(!empty($likeName)){
    		foreach($likeName as $k => $name){
	    		$res = $this->where($k,'like','%'.$name.'%');
	    	}
	    	return $res->where($where)->paginate(5);
    	}else{
    		return $this->where($where)->paginate(5);
    	}
    }

    public function deleteone($id){
    	return $this->where(array('id'=>$id))->delete();
    }
}
